﻿@using Covenant.Models.Covenant
@{
    Layout = "_DataLayout";
    ViewData["Title"] = "Data";
    IEnumerable<CapturedPasswordCredential> PasswordCredentials = ViewBag.PasswordCredentials;
    IEnumerable<CapturedHashCredential> HashCredentials = ViewBag.HashCredentials;
    IEnumerable<CapturedTicketCredential> TicketCredentials = ViewBag.TicketCredentials;
    IEnumerable<DownloadEvent> DownloadEvents = ViewBag.DownloadEvents;
    IEnumerable<ScreenshotEvent> ScreenshotEvents = ViewBag.ScreenshotEvents;
}

<div class="d-flex justify-content-between flex-wrap flex-md-nowrap pb-2 mb-3">
    <h1 class="h2">Data</h1>
</div>

<ul class="nav nav-tabs mb-3" id="data-tab" role="tablist">
    <li class="nav-item">
        <a class="nav-link active" id="credentials-tab" data-toggle="tab" href="#credentials" role="tab" aria-controls="credentials" aria-selected="true">
            <span data-feather="key"></span>
            Credentials
        </a>
    </li>
    <li class="nav-item">
        <a class="nav-link" id="indicators-tab" data-toggle="tab" href="#indicators" role="tab" aria-controls="indicators" aria-selected="false">
            <span data-feather="activity"></span>
            Indicators
        </a>
    </li>
    <li class="nav-item">
        <a class="nav-link" id="downloads-tab" data-toggle="tab" href="#downloads" role="tab" aria-controls="downloads" aria-selected="false">
            <span data-feather="download"></span>
            Downloads
        </a>
    </li>
    <li class="nav-item">
        <a class="nav-link" id="screenshots-tab" data-toggle="tab" href="#screenshots" role="tab" aria-controls="screenshots" aria-selected="false">
            <span data-feather="camera"></span>
            Screenshots
        </a>
    </li>
    @*
        <li class="nav-item">
            <a class="nav-link" id="keylogger-tab" data-toggle="tab" href="#keylogger" role="tab" aria-controls="keylogger" aria-selected="false">
                <span data-feather="message-square"></span>
                Keylogger
            </a>
        </li>
    *@
</ul>

<div class="tab-content" id="grunt-tab-content">
    <div class="tab-pane fade" id="credentials" role="tabpanel" aria-labelledby="credentials-tab">
        @{
            await Html.RenderPartialAsync("../Credential/_CredentialTables");
        }
    </div>
    <div class="tab-pane fade" id="indicators" role="tabpanel" aria-labelledby="indicators-tab">
        @{
            await Html.RenderPartialAsync("../Indicator/_IndicatorTables");
        }
    </div>
    <div class="tab-pane fade" id="downloads" role="tabpanel" aria-labelledby="downloads-tab">
        <div class="table-responsive">
            <table id="download-table" class="table table-bordered">
                <thead>
                    <tr>
                        <th>FileName</th>
                        <th>Size</th>
                        <th>Download</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var download in DownloadEvents)
                    {
                        <tr>
                            <td>
                                @download.FileName
                            </td>
                            <td>
                                @System.Convert.FromBase64String(download.FileContents).Length
                            </td>
                            <td>
                                <a class="btn btn-primary" asp-controller="Data" asp-action="Download" asp-route-id="@download.Id">
                                    <span data-feather="download"></span>
                                    Download
                                </a>
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
    </div>
    <div class="tab-pane fade" id="screenshots" role="tabpanel" aria-labelledby="screenshots-tab">
        <div class="table-responsive">
            <table id="screenshot-table" class="table table-bordered">
                <thead>
                    <tr>
                        <th>FileName</th>
                        <th>Size</th>
                        <th>Image</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var screenshot in ScreenshotEvents)
                    {
                        <tr>
                            <td>
                                @screenshot.FileName
                            </td>
                            <td>
                                @System.Convert.FromBase64String(screenshot.FileContents).Length
                            </td>
                            <td>
                                <img style="max-width:100%" src="data:image/png;base64, @screenshot.FileContents" />
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
    </div>
    @*
        <div class="tab-pane fade" id="keylogger" role="tabpanel" aria-labelledby="keylogger-tab">
            <div class="table-responsive">
                <table id="download-table" class="table table-bordered">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>FileName</th>
                            <th>Size</th>
                            <th>Download</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>
                                <a asp-action="Download" asp-route-id="1">
                                    Download1
                                </a>
                            </td>
                            <td>FileName1</td>
                            <td>100MB</td>
                            <td>
                                <a class="btn btn-link" asp-action="DownloadDownload" asp-route-id="1">
                                    Download
                                </a>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    *@
</div>

@section Scripts {
    <script type="text/javascript">"use strict";

        $(document).ready(function () {
            $("#credentials-tab").tab('show');
            $('#password-table').DataTable({
                "info": false,
                "pageLength": 50,
                "sDom": 'Rfrtilp'
            });
            $('#hash-table').DataTable({
                "info": false,
                "pageLength": 50,
                "sDom": 'Rfrtilp'
            });
            $('#ticket-table').DataTable({
                "info": false,
                "pageLength": 50,
                "sDom": 'Rfrtilp'
            });
            $('#target-table').DataTable({
                "info": false,
                "pageLength": 50,
                "sDom": 'Rfrtilp'
            });
            $('#network-table').DataTable({
                "info": false,
                "pageLength": 50,
                "sDom": 'Rfrtilp'
            });
            $('#file-table').DataTable({
                "info": false,
                "pageLength": 50,
                "sDom": 'Rfrtilp'
            });
        });</script>
}
